package com.kikt.closeappdemo;

import android.app.Service;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.IBinder;
import android.widget.Toast;

public class CheckHomeService extends Service {

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        //注册广播
        registerReceiver(new BackgroundReceiver(new BackgroundReceiver.BackgroundListener() {
            @Override
            public void onDesktop() {
                Toast.makeText(CheckHomeService.this, "desktop", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onChangeApp() {
                Toast.makeText(CheckHomeService.this, "changeApp", Toast.LENGTH_SHORT).show();
            }
        }), new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public IBinder onBind(Intent intent) {
        throw new UnsupportedOperationException("Not yet implemented");
    }
}
